<!--

    Copyright (C) 2015 The Gravitee team (http://gravitee.io)

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

            http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<md-content class="gravitee-no-sidenav-container" flex>
  <div class="login-page">
    <div class="form">
      <div class="gravitee-no-sidenav-header" layout="column">
        <label>Sign Up</label>
      </div>
      <form name="formRegistration" ng-submit="$ctrl.register()" layout="column">
        <md-input-container class="md-icon-float">
          <label>First name</label>
          <input ng-model="$ctrl.user.firstname" type="text" required autofocus />
        </md-input-container>

        <md-input-container class="md-icon-float">
          <label>Last name</label>
          <input ng-model="$ctrl.user.lastname" type="text" required />
        </md-input-container>

        <md-input-container class="md-icon-float">
          <label>Email</label>
          <input ng-model="$ctrl.user.email" type="email" required />
        </md-input-container>

        <md-input-container class="md-icon-float" ng-if="$ctrl.fields && $ctrl.fields.length > 0" ng-repeat="field in $ctrl.fields">
          <label>{{field.label}}</label>
          <input
            ng-if="!field.values || field.values.length == 0"
            ng-model="$ctrl.user.customFields[field.key]"
            type="text"
            ng-required="field.required"
          />
          <md-select
            style="padding-bottom: 2em"
            ng-if="field.values && field.values.length > 0"
            ng-model="$ctrl.user.customFields[field.key]"
            ng-required="field.required"
          >
            <md-option ng-value="value" ng-repeat="value in field.values">{{ value }}</md-option>
          </md-select>
        </md-input-container>

        <md-button
          type="submit"
          class="md-raised md-primary"
          ng-disabled="formRegistration.$invalid || formRegistration.$pristine || isLoading"
        >
          Sign up
        </md-button>

        <br />

        <p class="text-center text-muted">
          <small>I have already an account! <a ui-sref="login">Sign in</a></small>
        </p>
      </form>
    </div>
  </div>
</md-content>
